package com.aionengine.gameserver.services.custom;

import com.aionengine.gameserver.dataholders.DataManager;
import com.aionengine.gameserver.model.TeleportAnimation;
import com.aionengine.gameserver.model.gameobjects.player.Player;
import com.aionengine.gameserver.services.instance.InstanceService;
import com.aionengine.gameserver.services.teleport.TeleportService2;
import com.aionengine.gameserver.utils.PacketSendUtility;
import com.aionengine.gameserver.world.WorldMapInstance;

/**
 *
 * @author BlackCore
 */
public class Farm {
    
    public static void teleportToFarm(Player player) {
		if (player.isInTeam()) {
			PacketSendUtility.sendMessage(player, "Sal del grupo donde estas.");
			return;
		}
		if (player.getPortalCooldownList().isPortalUseDisabled(300400000)) {
			long time = player.getPortalCooldownList().getPortalCooldown(300400000);
			PacketSendUtility.sendMessage(player, "Usted no puede entrar, espere " + ((time - System.currentTimeMillis()) / 1000) / 60 + " min");
			return;
		}
		WorldMapInstance newInstance = InstanceService.getNextAvailableInstance(300400000);
		InstanceService.registerPlayerWithInstance(newInstance, player);
		TeleportService2.teleportTo(player, 300400000, newInstance.getInstanceId(), 529.35f, 693.39f, 178.4f, (byte) 40, TeleportAnimation.BEAM_ANIMATION);
		player.getPortalCooldownList().addPortalCooldown(300400000, DataManager.INSTANCE_COOLTIME_DATA.getInstanceEntranceCooltime(player, newInstance.getMapId()));
	}
    
}
